<template>
    <div>
        <div class="configHead"  :style="styleObj">子设备信息:<span style="color: #FF5722;font-size:0.25rem;">{{slaveTip}}</span></div>
		<div class="configBox" style="padding-top:0.1rem;border-bottom:1px dashed #ccc;">
			<div><span>子设备名称：</span>{{slaveInfo.slave_name}}</div>
			<div><span>子设备站号：</span>{{slaveInfo.slave_addr}}</div>
			<div><span>子设备ID：</span>{{slaveInfo.slave_no}}</div>
			<div><span>协议：</span>{{protocolToUpper(slaveInfo.slave_protocol)}}</div>
			<div><span>端口：</span>{{channelToUpper(slaveInfo.channel_type)}}</div>
		</div>
		<div class="configBox" v-if="slaveInfo.slave_protocol.indexOf('rtu_master')>=0 || slaveInfo.slave_protocol.indexOf('ascii')>=0">
			<div><span>轮询周期：</span>{{slaveInfo.slave_config.poll_cycle}}s</div>
			<div><span>指令间隔：</span>{{slaveInfo.slave_config.poll_interval}}ms</div>
			<div><span>超时时长：</span>{{slaveInfo.slave_config.response_timeout}}ms</div>
			<div><span>4区16位写功能选择：</span>{{slaveInfo.slave_config.write16_cmd}}</div>
			<div><span>16位整数解码顺序：</span>{{slaveInfo.slave_config.int16_order}}</div>
			<div><span>32位整数解码顺序：</span>{{slaveInfo.slave_config.int32_order}}</div>
			<div><span>32位浮点数解码顺序：</span>{{slaveInfo.slave_config.float_order}}</div>
			<div><span>64位整数解码顺序：</span>{{slaveInfo.slave_config.int64_order}}</div>
			<div><span>64位浮点数解码顺序：</span>{{slaveInfo.slave_config.double_order}}</div>
			<div><span>CRC检验方式：</span>{{slaveInfo.slave_config.crc_mode}}</div>
			<div><span>最大采集长度：</span>{{slaveInfo.slave_config.max_length}}</div>
      <div><span>非连续地址间隔：</span>{{slaveInfo.slave_config.framing_interval}}</div>
      <div><span>ASCII排序：</span>{{slaveInfo.slave_config.ascii_order==0?'AB':'BA'}}</div>
			<div v-if="version==3 && slaveInfo.slave_config.state_reg" style="border-top:1px dashed #ccc;">
				<div><span>下发频率：</span>{{slaveInfo.slave_config.state_reg.push_interval}}s</div>
				<div><span>心跳使能：</span>{{slaveInfo.slave_config.state_reg.ping_enable==1?'开':'关'}}</div>
				<div><span>心跳地址：</span>{{slaveInfo.slave_config.state_reg.ping_address}}</div>
				<div><span>状态使能：</span>{{slaveInfo.slave_config.state_reg.state_enable==1?'开':'关'}}</div>
				<div><span>状态地址：</span>{{slaveInfo.slave_config.state_reg.state_address}}</div>
			</div>
		</div>
		<div class="configBox" v-if="slaveInfo.slave_protocol.indexOf('lient')>=0 || slaveInfo.slave_protocol.indexOf('ver')>=0">
			<div><span>工作模式：</span>{{slaveInfo.slave_config.work_mode==0?'边缘采集':'数据透传'}}</div>
      <div><span>轮询周期：</span>{{slaveInfo.slave_config.poll_cycle}}s</div>
			<div><span>指令间隔：</span>{{slaveInfo.slave_config.poll_interval}}ms</div>
			<div><span>超时时长：</span>{{slaveInfo.slave_config.response_timeout}}ms</div>
			<div><span>4区16位写功能选择：</span>{{slaveInfo.slave_config.write16_cmd}}</div>
			<div><span>16位整数解码顺序：</span>{{slaveInfo.slave_config.int16_order}}</div>
			<div><span>32位整数解码顺序：</span>{{slaveInfo.slave_config.int32_order}}</div>
			<div><span>32位浮点数解码顺序：</span>{{slaveInfo.slave_config.float_order}}</div>
			<div><span>64位整数数解码顺序：</span>{{slaveInfo.slave_config.int64_order}}</div>
			<div><span>64位浮点数解码顺序：</span>{{slaveInfo.slave_config.double_order}}</div>
			<!-- <div><span>CRC检验方式：</span>{{slaveInfo.slave_config.crc_mode}}</div> -->
			<div><span>最大采集长度：</span>{{slaveInfo.slave_config.max_length}}</div>
			<div><span>Server_IP：</span>{{slaveInfo.slave_config.server_ip}}</div>
			<div><span>Server_Port：</span>{{slaveInfo.slave_config.server_port}}</div>
      <div><span>非连续地址间隔：</span>{{slaveInfo.slave_config.framing_interval}}</div>
      <div><span>ASCII排序：</span>{{slaveInfo.slave_config.ascii_order==0?'AB':'BA'}}</div>
			<div v-if="version==3 && slaveInfo.slave_config.state_reg" style="border-top:1px dashed #ccc;">
				<div><span>下发频率：</span>{{slaveInfo.slave_config.state_reg.push_interval}}s</div>
				<div><span>心跳使能：</span>{{slaveInfo.slave_config.state_reg.ping_enable==1?'开':'关'}}</div>
				<div><span>心跳地址：</span>{{slaveInfo.slave_config.state_reg.ping_address}}</div>
				<div><span>状态使能：</span>{{slaveInfo.slave_config.state_reg.state_enable==1?'开':'关'}}</div>
				<div><span>状态地址：</span>{{slaveInfo.slave_config.state_reg.state_address}}</div>
			</div>
		</div>
		<div class="configBox" v-if="slaveInfo.slave_protocol=='modbus'">
      <div v-if="version==3">
        <div><span>COM1使能：</span>{{slaveInfo.slave_config.com1==1?'开':'关'}}</div>
        <div><span>COM2使能：</span>{{slaveInfo.slave_config.com2==1?'开':'关'}}</div>
        <div><span>COM3使能：</span>{{slaveInfo.slave_config.com3==1?'开':'关'}}</div>
        <div><span>COM4使能：</span>{{slaveInfo.slave_config.com4==1?'开':'关'}}</div>
        <div><span>COM5使能：</span>{{slaveInfo.slave_config.com5==1?'开':'关'}}</div>
        <div><span>COM6使能：</span>{{slaveInfo.slave_config.com6==1?'开':'关'}}</div>
        <div><span>COM7使能：</span>{{slaveInfo.slave_config.com7==1?'开':'关'}}</div>
        <div><span>COM8使能：</span>{{slaveInfo.slave_config.com8==1?'开':'关'}}</div>
        <div><span>Ethernet1使能：</span>{{slaveInfo.slave_config.ethernet1==1?'开':'关'}}</div>
        <div><span>Ethernet2使能：</span>{{slaveInfo.slave_config.ethernet2==1?'开':'关'}}</div>
        <div><span>Zigbee1使能：</span>{{slaveInfo.slave_config.zigbee1==1?'开':'关'}}</div>
        <div><span>Zigbee2使能：</span>{{slaveInfo.slave_config.zigbee2==1?'开':'关'}}</div>
        <div><span>数据映射：</span>{{slaveInfo.slave_config.data_map==1?'开':'关'}}</div>
        <div><span>响应延时：</span>{{slaveInfo.slave_config.response_delay}}s</div>
      </div>
      <!-- <div><span>非连续地址间隔：</span>{{slaveInfo.slave_config.framing_interval}}</div> -->
      <!-- <div><span>ASCII排序：</span>{{slaveInfo.slave_config.ascii_order==0?'AB':'BA'}}</div> -->
			<div v-if="version==3 && slaveInfo.slave_config.state_reg" style="border-top:1px dashed #ccc;">
				<div><span>下发频率：</span>{{slaveInfo.slave_config.state_reg.push_interval}}s</div>
				<div><span>心跳使能：</span>{{slaveInfo.slave_config.state_reg.ping_enable==1?'开':'关'}}</div>
				<div><span>心跳地址：</span>{{slaveInfo.slave_config.state_reg.ping_address}}</div>
				<div><span>状态使能：</span>{{slaveInfo.slave_config.state_reg.state_enable==1?'开':'关'}}</div>
				<div><span>状态地址：</span>{{slaveInfo.slave_config.state_reg.state_address}}</div>
			</div>
      <div v-if="version==4">
        <div v-if="slaveInfo.slave_config.hasOwnProperty('com1')"><span>COM1使能：</span>{{slaveInfo.slave_config.com1==1?'开':'关'}}</div>
        <div v-if="slaveInfo.slave_config.hasOwnProperty('com2')"><span>COM2使能：</span>{{slaveInfo.slave_config.com2==1?'开':'关'}}</div>
        <div v-if="slaveInfo.slave_config.hasOwnProperty('com3')"><span>COM3使能：</span>{{slaveInfo.slave_config.com3==1?'开':'关'}}</div>
        <div v-if="slaveInfo.slave_config.hasOwnProperty('com4')"><span>COM4使能：</span>{{slaveInfo.slave_config.com4==1?'开':'关'}}</div>
        <div v-if="slaveInfo.slave_config.hasOwnProperty('com5')"><span>COM5使能：</span>{{slaveInfo.slave_config.com5==1?'开':'关'}}</div>
        <div v-if="slaveInfo.slave_config.hasOwnProperty('com6')"><span>COM6使能：</span>{{slaveInfo.slave_config.com6==1?'开':'关'}}</div>
        <div v-if="slaveInfo.slave_config.hasOwnProperty('com7')"><span>COM7使能：</span>{{slaveInfo.slave_config.com7==1?'开':'关'}}</div>
        <div v-if="slaveInfo.slave_config.hasOwnProperty('com8')"><span>COM8使能：</span>{{slaveInfo.slave_config.com8==1?'开':'关'}}</div>
        <div v-if="slaveInfo.slave_config.hasOwnProperty('ethernet1')"><span>Ethernet1使能：</span>{{slaveInfo.slave_config.ethernet1==1?'开':'关'}}</div>
        <div v-if="slaveInfo.slave_config.hasOwnProperty('ethernet2')"><span>Ethernet2使能：</span>{{slaveInfo.slave_config.ethernet2==1?'开':'关'}}</div>
        <div v-if="slaveInfo.slave_config.hasOwnProperty('ethernet1_port')"><span>Ethernet1端口：</span>{{slaveInfo.slave_config.ethernet1_port}}</div>
        <div v-if="slaveInfo.slave_config.hasOwnProperty('ethernet2_port')"><span>Ethernet2端口：</span>{{slaveInfo.slave_config.ethernet2_port}}</div>
        <div v-if="slaveInfo.slave_config.hasOwnProperty('zigbee1')"><span>Zigbee1使能：</span>{{slaveInfo.slave_config.zigbee1==1?'开':'关'}}</div>
        <div v-if="slaveInfo.slave_config.hasOwnProperty('zigbee2')"><span>Zigbee2使能：</span>{{slaveInfo.slave_config.zigbee2==1?'开':'关'}}</div>
        <div><span>数据映射：</span>{{slaveInfo.slave_config.data_map==1?'开':'关'}}</div>
        <div><span>响应延时：</span>{{slaveInfo.slave_config.response_delay}}s</div>
      </div>
		</div>
		<div class="configBox" v-if="slaveInfo.slave_protocol.indexOf('pi')>=0 || slaveInfo.slave_protocol.indexOf('rogram')>=0">
			<div v-if="slaveInfo.slave_protocol.indexOf('rogram')>=0"><span>PLC类型：</span>{{slaveInfo.slave_config.plc_type | protocolPLC}}</div>
			<div><span>轮询周期：</span>{{slaveInfo.slave_config.poll_cycle}}s</div>
			<div><span>指令间隔：</span>{{slaveInfo.slave_config.poll_interval}}ms</div>
			<div><span>超时时长：</span>{{slaveInfo.slave_config.response_timeout}}ms</div>
			<div v-if="version==3 && slaveInfo.slave_config.state_reg" style="border-top:1px dashed #ccc;">
				<div><span>下发频率：</span>{{slaveInfo.slave_config.state_reg.push_interval}}s</div>
				<div><span>心跳使能：</span>{{slaveInfo.slave_config.state_reg.ping_enable==1?'开':'关'}}</div>
				<div><span>心跳地址：</span>{{slaveInfo.slave_config.state_reg.ping_address}}</div>
				<div><span>状态使能：</span>{{slaveInfo.slave_config.state_reg.state_enable==1?'开':'关'}}</div>
				<div><span>状态地址：</span>{{slaveInfo.slave_config.state_reg.state_address}}</div>
			</div>
		</div>
		<div class="configBox" v-if="slaveInfo.slave_protocol.indexOf('645')>=0">
			<div><span>轮询周期：</span>{{slaveInfo.slave_config.poll_cycle}}s</div>
			<div><span>指令间隔：</span>{{slaveInfo.slave_config.poll_interval}}ms</div>
			<div><span>超时时长：</span>{{slaveInfo.slave_config.response_timeout}}ms</div>
		</div>
		<div class="configBox"
			v-if="slaveInfo.slave_protocol.indexOf('mart')>=0 || slaveInfo.slave_protocol.indexOf('1200')>=0 || slaveInfo.slave_protocol.indexOf('1500')>=0 || slaveInfo.slave_protocol.indexOf('300')>=0 ||  slaveInfo.slave_protocol.toLowerCase()=='s7_200'">
			<div><span>工作模式：</span>{{slaveInfo.slave_config.work_mode==0?'边缘采集':'数据透传'}}</div>
      <div><span>轮询周期：</span>{{slaveInfo.slave_config.poll_cycle}}s</div>
			<div><span>指令间隔：</span>{{slaveInfo.slave_config.poll_interval}}ms</div>
			<div><span>超时时长：</span>{{slaveInfo.slave_config.response_timeout}}ms</div>
			<div><span>PLC IP：</span>{{slaveInfo.slave_config.server_ip}}</div>
			<div><span>PLC端口：</span>{{slaveInfo.slave_config.server_port}}</div>
			<div><span>机架号：</span>{{slaveInfo.slave_config.rack_num}}</div>
			<div><span>槽号：</span>{{slaveInfo.slave_config.slot_num}}</div>
			<div v-if="version==3 && slaveInfo.slave_config.state_reg" style="border-top:1px dashed #ccc;">
				<div><span>下发频率：</span>{{slaveInfo.slave_config.state_reg.push_interval}}s</div>
				<div><span>心跳使能：</span>{{slaveInfo.slave_config.state_reg.ping_enable==1?'开':'关'}}</div>
				<div><span>心跳地址：</span>{{slaveInfo.slave_config.state_reg.ping_address}}</div>
				<div><span>状态使能：</span>{{slaveInfo.slave_config.state_reg.state_enable==1?'开':'关'}}</div>
				<div><span>状态地址：</span>{{slaveInfo.slave_config.state_reg.state_address}}</div>
			</div>
		</div>
		<div class="configBox" v-if="slaveInfo.slave_protocol.indexOf('erial')>=0">
			<div><span>PLC类型：</span>{{slaveInfo.slave_config.plc_type | protocolPLC}}</div>
			<div><span>协议格式：</span>{{slaveInfo.slave_config.protocol_format==0?1:4}}</div>
			<div><span>轮询周期：</span>{{slaveInfo.slave_config.poll_cycle}}s</div>
			<div><span>指令间隔：</span>{{slaveInfo.slave_config.poll_interval}}ms</div>
			<div><span>超时时长：</span>{{slaveInfo.slave_config.response_timeout}}ms</div>
			<div><span>是否效验：</span>{{slaveInfo.slave_config.is_check==1?'是':'否'}}</div>
			<div v-if="version==3 && slaveInfo.slave_config.state_reg" style="border-top:1px dashed #ccc;">
				<div><span>下发频率：</span>{{slaveInfo.slave_config.state_reg.push_interval}}s</div>
				<div><span>心跳使能：</span>{{slaveInfo.slave_config.state_reg.ping_enable==1?'开':'关'}}</div>
				<div><span>心跳地址：</span>{{slaveInfo.slave_config.state_reg.ping_address}}</div>
				<div><span>状态使能：</span>{{slaveInfo.slave_config.state_reg.state_enable==1?'开':'关'}}</div>
				<div><span>状态地址：</span>{{slaveInfo.slave_config.state_reg.state_address}}</div>
			</div>

		</div>
    </div>
</template>
<script>
    export default {
        name: 'SlaveInfo',
        data() {
            return {

            }
        },
        props: ['slaveInfo', 'slaveTip', 'styleObj','version']
    }
</script>
<style lang="">
    .configHead {
        min-height: 0.5rem;
		max-height: 1rem;
        line-height: 0.5rem;
        font-size: 0.3rem;
        text-align: left;
        /* margin-bottom:0.2rem; */
        border-bottom: 1px solid #ccc;
    }

    .configBox {
        width: 100%;
        padding: 0;
        /* padding-top: 0.1rem; */
        text-align: left;
        font-size: 0.3rem;
        line-height: 0.5rem;
        /* border:1px solid red; */
    }

    .configBox span {
        display: inline-block;
        min-width: 0.6rem;
        /* width:auto; */
        text-align: right;
        /*text-align:right;*/
    }
</style>
